From 7ee33d4974664ce40a37c1398e788fcf38555ab7 Mon Sep 17 00:00:00 2001 From: robertl Date: Sun, 6 Oct 2002 02:47:53 +0000 Subject: [PATCH] Add topousa4/xmap format. --- gpsbabel/README | 8 ++++++++ gpsbabel/csv.c | 31 ++++++++++++++++++++++++++++--- gpsbabel/reference/xmap | 4 ++++ gpsbabel/testo | 17 ++++++++++++++--- gpsbabel/vecs.c | 6 ++++++ 5 files changed, 60 insertions(+), 6 deletions(-) create mode 100644 gpsbabel/reference/xmap diff --git a/gpsbabel/README b/gpsbabel/README index e222bd5a1..f6bcbbfff 100644 --- a/gpsbabel/README +++ b/gpsbabel/README @@ -87,6 +87,14 @@ THE FORMATS There are a billion variants of Comma Separated Value data. This is the one that makes Delorme S&A Deluxe 9 happy. + XMap + + Delorme TopoUSA/XMap Conduit is one of the billion CSV variants + mentioned above. It's just like S&A with the addition of a + completely pointless line at the beginning and end of the file. + This is the format used to hot-sync to XMap from withing TopoUSA. + Done with help of Dan Edwards. + MAPSEND Magellan was smart enough to document their file format to make diff --git a/gpsbabel/csv.c b/gpsbabel/csv.c index f7c70cd32..8f2df9dc9 100644 --- a/gpsbabel/csv.c +++ b/gpsbabel/csv.c @@ -53,12 +53,27 @@ wr_init(const char *fname) } } +static void +xmap_wr_init(const char *fname) +{ + wr_init(fname); + fprintf(file_out, "BEGIN SYMBOL\n"); +} + + static void wr_deinit(void) { fclose(file_out); } +static void +xmap_wr_deinit(void) +{ + fprintf(file_out, "END\n"); + wr_deinit(); +} + static void data_read(void) { @@ -107,9 +122,10 @@ data_read(void) wpt_tmp->creation_time = time(NULL); /* We'll make up our own shortname. */ - wpt_tmp->shortname = mkshort(wpt_tmp->description); - - waypt_add(wpt_tmp); + if (wpt_tmp->description) { + wpt_tmp->shortname = mkshort(wpt_tmp->description); + waypt_add(wpt_tmp); + } } else { /* empty line */ @@ -154,3 +170,12 @@ ff_vecs_t csv_vecs = { data_read, data_write, }; + +ff_vecs_t xmap_vecs = { + rd_init, + xmap_wr_init, + rd_deinit, + xmap_wr_deinit, + data_read, + data_write, +}; diff --git a/gpsbabel/reference/xmap b/gpsbabel/reference/xmap new file mode 100644 index 000000000..b5911f218 --- /dev/null +++ b/gpsbabel/reference/xmap @@ -0,0 +1,4 @@ +BEGIN SYMBOL +36.04768, -86.87918, Tennessee Scavenger Hunt Cache +35.95765, -86.67185, Stonebrook-Greystone +END diff --git a/gpsbabel/testo b/gpsbabel/testo index cd5f5f874..004048717 100755 --- a/gpsbabel/testo +++ b/gpsbabel/testo @@ -53,9 +53,19 @@ diff ${TMPDIR}/tiger ${TMPDIR}/tiger2 # CSV (Comma separated value) data. -#${PNAME} -i geo -f geocaching.loc -o csv -F ${TMPDIR}/csv.csv -#${PNAME} -i csv -f ${TMPDIR}/csv.csv -o gpsutil -F ${TMPDIR}/csv2.csv -#diff ${TMPDIR}/csv2.csv ${TMPDIR}/gu.wpt +${PNAME} -i geo -f geocaching.loc -o csv -F ${TMPDIR}/csv.csv +${PNAME} -i csv -f ${TMPDIR}/csv.csv -o csv -F ${TMPDIR}/csv2.csv +diff ${TMPDIR}/csv2.csv ${TMPDIR}/csv.csv + +# +# Delorme TopoUSA 4 is a CSV strain. +# +rm -f ${TMPDIR}/xmap-1.gpx ${TMPDIR}/xmap-2.gpx ${TMPDIR}/xmap +${PNAME} -i xmap -f reference/xmap -o xmap -F ${TMPDIR}/xmap +${PNAME} -i xmap -f reference/xmap -o gpx -F ${TMPDIR}/xmap-1.gpx +${PNAME} -i xmap -f ${TMPDIR}/xmap -o gpx -F ${TMPDIR}/xmap-2.gpx +diff ${TMPDIR}/xmap-1.gpx ${TMPDIR}/xmap-2.gpx +diff reference/xmap ${TMPDIR}/xmap # PCX (Garmin mapsource import) file format rm -f ${TMPDIR}/mm.pcx ${TMPDIR}/pcx.gps @@ -96,3 +106,4 @@ diff ${TMPDIR}/ozi.ozi reference # identical reference. ${PNAME} -i holux -f reference/paris.wpo -o holux -F ${TMPDIR}/paris.wpo diff reference/paris.wpo ${TMPDIR}/paris.wpo + diff --git a/gpsbabel/vecs.c b/gpsbabel/vecs.c index 4cb72c8d5..db1e0691d 100644 --- a/gpsbabel/vecs.c +++ b/gpsbabel/vecs.c @@ -46,6 +46,7 @@ extern ff_vecs_t mxf_vecs; extern ff_vecs_t holux_vecs; extern ff_vecs_t ozi_vecs; extern ff_vecs_t dna_vecs; +extern ff_vecs_t xmap_vecs; static vecs_t vec_list[] = { @@ -99,6 +100,11 @@ vecs_t vec_list[] = { "csv", "Comma separated values" }, + { + &xmap_vecs, + "xmap", + "Delorme Topo USA4/XMap Conduit" + }, { &dna_vecs, "dna", -- 2.30.2